<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/5
 * Time: 15:39
 */

namespace app\index\controller;


use app\index\model\WXJSSDK;

class Wx extends BaseController
{


    public function demo()
    {
        $jssdk = new WXJSSDK();
        $signPackage = $jssdk->getSignPackage();
        $this->assign("signPackage", $signPackage);
        return view();
    }

    public function getUserInfo()
    {
        $redirect=url("onUserInfoReturn","",true,true);
        $jssdk = new WXJSSDK();
        $this->redirect($jssdk->buildAuthUrl($redirect,true));
    }

    public function getUserInfoBase()
    {
        $redirect=url("onUserInfoReturn","",true,true);
        $jssdk = new WXJSSDK();
        $this->redirect($jssdk->buildAuthUrl($redirect));
    }


    public function onUserInfoReturn()
    {
        $jssdk = new WXJSSDK();
        if ($_GET["state"]==1)
        {
            $jssdk->queryUserToken($_GET["code"]);
        }

    }

    public function voice()
    {
        $jssdk = new WXJSSDK();
        $signPackage = $jssdk->getSignPackage();
        $this->assign("signPackage", $signPackage);
        return view();
    }



}